/**
 @file sys_usw_dtel.h

 @date 2019-02-13

 @version v1.0

*/
#ifndef _SYS_USW_DTEL_H
#define _SYS_USW_DTEL_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_const.h"
#include "ctc_packet.h"
#include "ctc_dtel.h"

/***************************************************************
 *
 *  Defines and Macros
 *
 ***************************************************************/
#define SYS_DTEL_REP_HASH_SIZE          64

#define SYS_DTEL_DBG_OUT(level, FMT, ...) \
    CTC_DEBUG_OUT(dtel, dtel, DTEL_SYS, level, FMT, ## __VA_ARGS__)

enum sys_dtel_rep_mode_e
{
    SYS_DTEL_REP_MODE_NONE,
    SYS_DTEL_REP_MODE_IPE,
    SYS_DTEL_REP_MODE_EPE,
    SYS_DTEL_REP_MODE_DONE
};

struct sys_int_pkt_info_s
{
    uint8  int_session;
    uint8  queue_id;
    uint8  from_ipe;
    uint8  is_postcard;
    uint32 queue_cnt;
    uint16 local_src_port;
    uint16 local_dst_port;
    uint32 hop_lantency;
    uint32 igs_timestamp;
    uint32 egs_port_load;
};
typedef struct sys_int_pkt_info_s sys_int_pkt_info_t;

struct sys_dtel_pkt_s
{
    /*key*/
    uint32 igs_ts;          /*ingress timestamp from chip*/
    uint16 local_src_port;  /*loacl src port*/
    uint8  hash;            /*header hash*/
    uint8  calc_key_len[0];
    /*ad*/
    uint8  mode;            /*0-none, 1-ipe, 2-epe, 3-done*/
    uint8  chip_id;
    uint8  session_id;      /*sesssion id*/
    uint8  rsv;
    uint32 last_ts;  /*last timestamp from system, unit: second*/
    ctc_pkt_buf_t pkt_buf;  /*packet buffer*/
    ctc_pkt_rx_t pkt_rx;
    sys_int_pkt_info_t int_pkt_info;
};
typedef struct sys_dtel_pkt_s sys_dtel_pkt_t;


extern int32
sys_usw_dtel_set_property(uint8 lchip, ctc_dtel_property_t type, void* value);

extern int32
sys_usw_dtel_get_property(uint8 lchip,ctc_dtel_property_t type, void* value);

extern int32
sys_usw_dtel_set_int_cfg(uint8 lchip, ctc_dtel_int_cfg_t* p_cfg);

extern int32
sys_usw_dtel_get_int_cfg(uint8 lchip, ctc_dtel_int_cfg_t* p_cfg);

extern int32
sys_usw_dtel_set_ifa_cfg(uint8 lchip, ctc_dtel_ifa_cfg_t *p_cfg);

extern int32
sys_usw_dtel_get_ifa_cfg(uint8 lchip, ctc_dtel_ifa_cfg_t *p_cfg);

extern int32
sys_usw_dtel_show_int_status(uint8 lchip);

extern int32
sys_usw_dtel_init(uint8 lchip, ctc_dtel_global_cfg_t* p_glb_cfg);

extern int32
sys_usw_dtel_deinit(uint8 lchip);

#ifdef __cplusplus
}
#endif

#endif

